﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace ServiceThuVien
{
    public class SQLServer
    {
        string conn = ConfigurationSettings.AppSettings["conn"].ToString();
        SqlConnection cn;

        // Get List Doc Gia
        public DataSet GetListDG()
        {
            cn = new SqlConnection(conn);

            string procName = "ListDG";
            DataSet ds = new DataSet();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = procName;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = cn;

            try
            {
                cn.Open();
                SqlDataAdapter adap = new SqlDataAdapter(cmd);
                adap.Fill(ds);
                cn.Close();
                return ds;
            }
            catch
            {
                return null;
            }
        }


        // Inser Doc Gia
        public DataSet InsertDG()
        {
            cn = new SqlConnection(conn);

            string procName = "InsertDG";
            DataSet ds = new DataSet();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = procName;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = cn;

            try
            {
                cn.Open();
                SqlDataAdapter adap = new SqlDataAdapter(cmd);
                adap.Fill(ds);
                cn.Close();
                return ds;
            }
            catch
            {
                return null;
            }
        }

        //Insert Loai Doc Gia


    }
}